/////////////////////////////////////////////////////////////////////////////
// Copyright(c) 2012-2015 purang All Rights Reserved
// Name:        condition_variable_wrapper.h
// Purpose:     
// Author:      syy
// Modified by: 
// Created:     2014/1/3 15:43
// RCS-ID:      
// Licence:     
/////////////////////////////////////////////////////////////////////////////

#ifndef PR_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_
#define PR_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_

#include "../typedefs.h"

namespace qb
{

	class CriticalSectionWrapper;

	class ConditionVariableWrapper
	{
	public:
		// Factory method, constructor disabled.
		static ConditionVariableWrapper* CreateConditionVariable();

		virtual ~ConditionVariableWrapper() {}

		// Calling thread will atomically release crit_sect and wait until next
		// some other thread calls Wake() or WakeAll().
		virtual void SleepCS(CriticalSectionWrapper& crit_sect) = 0;

		// Same as above but with a timeout.
		virtual bool SleepCS(CriticalSectionWrapper& crit_sect,
			unsigned long max_time_in_ms) = 0;

		// Wakes one thread calling SleepCS().
		virtual void Wake() = 0;

		// Wakes all threads calling SleepCS().
		virtual void WakeAll() = 0;
	};

}  // namespace qb

#endif  // PR_SYSTEM_WRAPPERS_INTERFACE_CONDITION_VARIABLE_WRAPPER_H_
